package com.xjj.datarources.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjj.datarources.base.DataSources;
import com.xjj.datarources.common.ResultVo;
import com.xjj.datarources.dao.DataSourceMapper;
import com.xjj.datarources.exception.APIException;
import com.xjj.datarources.service.DataSourceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @name: xjj
 * @date: 2021/5/31 13:19
 */

@Service
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSources> implements DataSourceService {


    @Resource
    private DataSourceMapper dataSourceMapper;

    @Override
    public Integer add(DataSources dataSources) {


        try {


            return dataSourceMapper.insert(dataSources);
        }catch (Exception e){
            throw new APIException("添加数据源时出现问题");
        }


    }

    @Override
    public Integer delete(String id) {
        return dataSourceMapper.deleteById(id);
    }


    @Override
    public Integer edit(DataSources dataSources) {
        return null;
    }


    @Override
    public List<DataSources> getAll() {
        return dataSourceMapper.selectList(null);
    }
}
